package com.wck.car.oyz;

import com.wck.car.model.CarSeriesDesc;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import javax.annotation.Resource;
import java.util.List;

public class CarSeriesUpdate {

    public static List<CarSeriesDesc> updateCarSeriesHtml(CarSeriesDesc carSeriesDesc){
        String body = SpiderCar.getBody("https://m.evpartner.com/" + carSeriesDesc.getCarSeriesLink());
        carSeriesDesc.setCarSeriesLink(null);
        Document document = Jsoup.parse(body);
        Element mrap_box = document.getElementsByClass("mrap_box").get(0);
        carSeriesDesc.setCarSeriesImg(mrap_box.getElementsByTag("img").get(0).attr("src"));   //找到汽车图片
        carSeriesDesc.setCarSeriesPhotoLink(mrap_box.getElementsByTag("a").get(0).attr("href"));    //找到汽车图片链接
        Element element = document.getElementsByClass("parameter-mrap").get(0);
        Elements ul = element.getElementsByTag("ul");
        Elements li = ul.get(0).getElementsByTag("li");
        carSeriesDesc.setCarSeriseEndurance(li.get(0).getElementsByTag("div").text());   //找到车辆纯电续航
        carSeriesDesc.setCarSeriesSize(li.get(1).getElementsByTag("div").text());    //找到货厢容积
        carSeriesDesc.setCarSeriesLoad(li.get(2).getElementsByTag("div").text());    //找到货厢额定载重
        carSeriesDesc.setCarSeriesMaxPower(li.get(3).getElementsByTag("div").text());   //找到最大功率
        carSeriesDesc.setCarSeriesLength(li.get(4).getElementsByTag("div").text());    //找到车身尺寸
        carSeriesDesc.setCarSeriesCapacity(li.get(5).getElementsByTag("div").text());   //找到搭载电量

        return null;
    }

}
